#include <iostream>
using std::cout;
using std::endl;

class Complex
{
public:
    Complex(int real,int image)
    : _real(real)
    , _image(image)
    {}

    void print() const{
        cout << _real << " + "
            << _image << "i"
            << endl;
    }

    int getReal() const{
        return _real;
    }

    int getImage() const{
        return _image;
    }
private:
    int _real;
    int _image;
};

//普通函数形式实现重载
Complex operator+(const Complex & c1,const Complex & c2)
{
    return Complex(c1.getReal() + c2.getReal(),
                   c1.getImage() + c2.getImage());

}

void test0(){
    int x = 1, y = 2;
    /* &(x + y); */
    cout << x + y << endl;


    Complex cx1(1,2);
    Complex cx2(3,4);
    cx1.getReal();
   
    //本质形式
    /* Complex cx3 = operator+(cx1,cx2); */
    Complex cx3 = cx1 + cx2;
    cx3.print();
}

int main(void){
    test0();
    return 0;
}
